package com.xiaohu.mayi_huiyuan.common;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletResponse;

@ControllerAdvice
public class GlobalExceptionHandler {

    private final static Logger logger = LoggerFactory.getLogger(Exception.class);

    @ExceptionHandler(Exception.class)
    public void   globalExceptionHandler(Exception e,HttpServletResponse response){
        logger.error("GlobalExceptionHandler:"+e);
        e.printStackTrace();
        try {
            response.sendRedirect("/500");
        }catch (Exception ex){
            logger.error("GlobalExceptionHandler:"+e);
        }

    }
}
